// MatchParaDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ultravioletcut.h"
#include "MatchParaDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMatchParaDlg dialog


CMatchParaDlg::CMatchParaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMatchParaDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMatchParaDlg)
	m_nMinAcceptance = 0;
	m_nAngleRang = 0;
	m_nMinDistance = 0;
	//}}AFX_DATA_INIT

	m_bDispSubImage = FALSE;
	m_bAngleFindType = FALSE;
}


void CMatchParaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMatchParaDlg)
	DDX_Text(pDX, IDC_EDIT_MINACCEPT, m_nMinAcceptance);
	DDX_Text(pDX, IDC_EDIT_ANGLERANG, m_nAngleRang);
	DDX_Text(pDX, IDC_EDIT_MINDISTANCE, m_nMinDistance);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMatchParaDlg, CDialog)
	//{{AFX_MSG_MAP(CMatchParaDlg)
	ON_BN_CLICKED(IDC_RADIO_IMAGE, OnRadioImage)
	ON_BN_CLICKED(IDC_RADIO_SUBIMAGE, OnRadioSubimage)
	ON_BN_CLICKED(IDC_RADIO_SINGLE, OnRadioSingle)
	ON_BN_CLICKED(IDC_RADIO_MULTI, OnRadioMulti)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMatchParaDlg message handlers

BOOL CMatchParaDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CButton* pBtn = NULL;
	if(m_bDispSubImage)
	{
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_SUBIMAGE);
		pBtn->SetCheck(TRUE);
	}
	else
	{
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_IMAGE);
		pBtn->SetCheck(TRUE);
	}

	if(m_bAngleFindType)
	{
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_SINGLE);
		pBtn->SetCheck(TRUE);
		
		OnRadioSingle();
	}
	else
	{
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_MULTI);
		pBtn->SetCheck(TRUE);
		
		OnRadioMulti();
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}


void CMatchParaDlg::OnRadioImage() 
{
	UpdateData();

	m_bDispSubImage = FALSE;
}

void CMatchParaDlg::OnRadioSubimage() 
{
	UpdateData();
	
	m_bDispSubImage = TRUE;
}

void CMatchParaDlg::OnRadioSingle() 
{
	UpdateData();

	m_bAngleFindType = TRUE;

	GetDlgItem(IDC_EDIT_ANGLERANG)->EnableWindow(TRUE);
	GetDlgItem(IDC_EDIT_MINACCEPT)->EnableWindow(FALSE);
	GetDlgItem(IDC_EDIT_MINDISTANCE)->EnableWindow(FALSE);

	/*CButton* pBtn = NULL;
	pBtn = (CButton*)GetDlgItem(IDC_RADIO_SINGLE);
	if(pBtn->GetCheck())
	{
		m_bAngleFindType = TRUE;
		
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_MULTI);
		pBtn->SetCheck(FALSE);
		
		GetDlgItem(IDC_EDIT_ANGLERANG)->EnableWindow(TRUE);
		GetDlgItem(IDC_EDIT_MINACCEPT)->EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_MINDISTANCE)->EnableWindow(FALSE);
	}*/
}

void CMatchParaDlg::OnRadioMulti() 
{
	UpdateData();

	m_bAngleFindType = FALSE;
	
	GetDlgItem(IDC_EDIT_ANGLERANG)->EnableWindow(FALSE);
	GetDlgItem(IDC_EDIT_MINACCEPT)->EnableWindow(TRUE);
	GetDlgItem(IDC_EDIT_MINDISTANCE)->EnableWindow(TRUE);

	/*CButton* pBtn = NULL;
	pBtn = (CButton*)GetDlgItem(IDC_RADIO_MULTI);
	if(pBtn->GetCheck())
	{	
		m_bAngleFindType = FALSE;
		
		pBtn = (CButton*)GetDlgItem(IDC_RADIO_SINGLE);
		pBtn->SetCheck(FALSE);
		
		GetDlgItem(IDC_EDIT_ANGLERANG)->EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_MINACCEPT)->EnableWindow(TRUE);
		GetDlgItem(IDC_EDIT_MINDISTANCE)->EnableWindow(TRUE);
	}*/
}
